<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

    <title>登录</title>
    <link href="./admin/css/bootstrap.min.css" rel="stylesheet">
    <link href="./admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="./admin/css/animate.css" rel="stylesheet">
    <link href="./admin/css/style.css" rel="stylesheet">
    <link href="./admin/css/login.css" rel="stylesheet">
    <script type="text/javascript" src="./admin/js/jquery.min.js"></script>
    <script type="text/javascript" src="./admin/js/layer/layer.js"></script>
</head>

<body class="gray-bg">
     <div class="middle-box text-center loginscreen  animated fadeInDown" style="padding-top:10%">
        <div class="row" style="border:1px solid #E6E6E6">
            <div style="padding:30px">
                <h2>健身管理</h2>
                <form class="m-t" role="form" action="">
                    <div class="form-group">
                        <input type="text" name="uname" class="form-control" placeholder="用户名" required="">
                    </div>
                    <div class="form-group">
                        <input type="password" name="pword" class="form-control" placeholder="密码" required="">
                    </div>
                    <button type="submit" class="btn btn-primary block full-width m-b">登 录</button>
                    <meta name="csrf-token" content="{{ csrf_token() }}">
                </form>
            </div>
        </div>
    </div>

    <script>
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });

        $(".m-t").submit(function(e){
            var uname = $("input[name='uname']").val();
            var pword = $("input[name='pword']").val();

            if(!uname){
                layer.msg('请填写用户名');
                return false;
            }

            if(!pword){
                layer.msg('请填写密码');
                return false;
            }

            $.ajax({
                url:"/login_do",    //请求的url地址
                dataType:"json",   //返回格式为json
                data:{"username":uname,"password":pword},    //参数值
                type:"POST",   //请求方式
                success:function(req){
                    //请求成功时处理

                    if(req.status == 0){
                        layer.msg(req.message);
                        return false;
                    }

                    self.location='/index';

                }
            });

            return false;
        });
    </script>
</body>
</html>
